<template>
      api
</template>

<script setup>
import {Web3} from "web3";

var web3 = new Web3(Web3.givenProvider || 'wss://holesky.infura.io/ws/v3/2667972a880d47e5a28af7f9ffe30fba');
console.log(web3)
// address : 0xbad67603D904858b40E9efE7D686944EBA69A727
// privateKey : 0x6d28d85b89704611764249620753b2c9a2d1bc78a0b8e33277f873c114709d43
// 创建账户 account="0xbad67603D904858b40E9efE7D686944EBA69A727"
let address="0xbad67603D904858b40E9efE7D686944EBA69A727";

// const account = web3.eth.accounts.create();
// console.log("account",account)
// address=account.address;


// 获取余额
web3.eth.getBalance(address).then((res)=>{
  console.log(`获取余额 ${res}`)
})
// 单位转换
const num1 = Web3.utils.toWei("0.001", "ether")
console.log(`以太转wei ${num1}`)

</script>



<style scoped lang="less">

</style>